package com.xiyou.luckdraw.web.controller;

import com.xiyou.luckdraw.api.dto.order.OrderInfoListRequest;
import com.xiyou.luckdraw.api.dto.order.OrderInfoListResponse;
import com.xiyou.luckdraw.api.service.IOrderInfoService;
import com.xiyou.luckdraw.common.constants.ResultCodeConstants;
import com.xiyou.luckdraw.common.result.ResponseData;
import com.xiyou.luckdraw.common.result.ResponseUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName: OrderInfoController
 * @Description:
 * @author: limingxing
 * @Date: 2019-10-09 21:13
 */
@RestController
@RequestMapping("/order")
@Api(value = "OrderInfoController", tags = {"订单接口"})
public class OrderInfoController {

    @Autowired
    private IOrderInfoService orderInfoService;

    @PostMapping("/list")
    @ApiOperation("查询订单列表")
    public ResponseData<OrderInfoListResponse> list(@RequestBody OrderInfoListRequest request) {
        OrderInfoListResponse response = orderInfoService.selectByPrimaryList(request);
        if (response.getCode().equals(ResultCodeConstants.SUCCESS.getCode())) {
            return new ResponseUtils().setData(response);
        }
        return new ResponseUtils().setData(response.getMsg());
    }
}
